<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
    <link href="/Content/Images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <title>Python快速开发框架->用户登录</title>
    <link rel="stylesheet" href="/Content/Styles/framework-login-30.css" />
    <script type="text/javascript" src="/Content/Scripts/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="/Content/Scripts/hpwf-core.js"></script>
    <!-- <script type="text/javascript" src="/Content/Scripts/cloud.js"></script> -->
    <script type="text/javascript" src="/Content/Scripts/jQuery.cookie.js"></script>
    <script type="text/javascript" src="/Content/Scripts/csrf.js"></script>
    <script type="text/javascript" language="javascript">
        $(function () {
            $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
            $(window).resize(function () {
                $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
            })
        });  
    </script>

    <script type="text/javascript" language="javascript">
        //检查浏览器是否支持
        var isIE = !!window.ActiveXObject;
        var isIE6 = isIE && !window.XMLHttpRequest;
        if (isIE6) {
            window.location.href = "../Error/Browser";
        }

        //提示信息
        function formMessage(msg, type) {
            $('.form-message').html('');
            $('.form-message').append('<div class="form-' + type + '-text">' + msg + '</div>');
        }

        //回车键
        document.onkeydown = function (e) {
            if (!e) e = window.event; //火狐中是 window.event
            if ((e.keyCode || e.which) == 13) {
                var btlogin = document.getElementById("btlogin");
                btlogin.focus();
                btlogin.click();
            }
        };

        $(function () {
            $("#btnLogin").click(function () {
                var account = $("#txtAccount").val();
                var password = $("#txtPassword").val();
                if (account == "") {
                    $("#txtAccount").focus();
                    formMessage('登录账户不能为空', 'warning');
                    return false;
                } else if (password == "") {
                    $("#txtPassword").focus();
                    formMessage('登录密码不能为空', 'warning');
                    return false;
                } else {
                    formMessage('正在登录...', 'succeed');
                    window.setTimeout(function () {
                        var postData = {
                            Account: escape(account),
                            //Password: escape($.md5(password))
                            Password: escape(password),
                            csrfmiddlewaretoken: '{{ csrf_token }}'
                        };
                        getAjax('/Admin/CheckLogin/', postData, function (rs) {
                            if (parseInt(rs) == -1) {
                                $("#txtAccount").focus();
                                formMessage('登录账户不存在', 'error');
                            } else if (parseInt(rs) == 2) {
                                $("#txtAccount").focus();
                                formMessage('登录账户被系统锁定', 'error');
                            } else if (parseInt(rs) == 4) {
                                $("#txtAccount").focus();
                                $("#txtPassword").val("");
                                formMessage('登录密码错误', 'error');
                            } else if (parseInt(rs) == 3) {
                                formMessage('登录验证成功,正在跳转首页', 'succeed');
                                //setInterval(Load, 1000);
                                Load()
                            } else {
                                alert(rs);
                            }
                        });
                    }, 500);
                }
            });
        });
        
    //登录加载
    function Load() {
        var Index = $.cookie('UIStyle');
       
        if (Index && Index == 'Tree') {
            window.location.href = '/Admin/TreeIndex/';
             //window.location.href = '/Admin/AccordionTreeIndex/';
        } else if (Index == 'AccordionTree') {
            window.location.href = '/Admin/AccordionTreeIndex/';
        } else {
             window.location.href = '/Admin/TreeIndex/';
        }
        return false;
    }
    </script>
</head>
<body style="background-color:#35444c; background-image:url(/Content/images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">
    <div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>
    <div class="logintop"> <span>Python Web Developemnt Framework</span>
      <ul>
        <li><a href="http://www.usable-programming.com">技术支持</a></li>
      </ul>
    </div>    
    <div class="loginbody"><!-- <span class="systemlogo"> --></span>    
      <div class="loginbox">
        <ul>
          <li>            
            <input id="txtAccount" type="text" class="loginuser" value="administrator"/>
          </li>
          <li>
            <input id="txtPassword" type="password" class="loginpwd" value="123456"/>
          </li>
          <li>
            <input id="btnLogin" type="button" class="loginbtn" value="登录"/>
            <label>
              <input name="" type="checkbox" value="" checked="checked" />
              记住密码</label>
            <!--<label><a href="#">忘记密码？</a></label> -->
          </li>
          <li>
            <div class="form-message"/>
          <li>
        </ul>
      </div>
    </div>
    <div class="loginbm">Usable-Programming版权所有</div>
    </body>
</html>
